﻿/* ######################################## *\
 * ### Copyright (C) 2009 AJ Ravindiran ### *
\* ######################################## */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using AJRavindiran.Jolt.RuneScape.Models.World;

namespace AJRavindiran.Jolt.RuneScape.Models
{
    /// <summary>
    /// Represents management for world-related models (mapdata).
    /// </summary>
    public class WorldManager
    {
        #region Fields
        private Dictionary<int, int[]> mapRegions = new Dictionary<int, int[]>();
        #endregion Fields

        #region Constructors
        /// <summary>
        /// Constructs a new world manager class.
        /// </summary>
        public WorldManager()
        {
            Jolt.GetLog().WriteInfo("Constucting world manager...");

            // If the file is missing, we will repack.
            if (!System.IO.File.Exists(@".\bin\data\mapdata\regions.dat"))
            {
                Jolt.GetLog().WriteWarn("Map regions data is missing. Repacking...");
                MapDataPacker.Pack();
            }

            // Load the regions into the regions.
            MapDataLoader.Load(mapRegions);
        }
        #endregion Constructors

        #region Methods
        /// <summary>
        /// Gets the map region according to it's id.
        /// </summary>
        /// <param name="id">The region's id.</param>
        /// <returns>Returns the map region keys associated with the given id.</returns>
        public int[] GetMapRegion(int id)
        {
            return mapRegions[id];
        }
        #endregion Methods
    }
}
